|
|
|
| |
|
|
|
|
The fifth rule of data normalization dictates that you should isolate related multiple relationships within a database. In other words, if several complex relationships exist in your database, separate each of the relationships into its own table. Databases that adhere to this rule are known to be in the Fifth Normal Form. |
|
|
|
|
|
|
|
|
|
|
The following list shows the relationships that have been exposed in this example: |
|
|
|
|
|
|
|
|
· Each department can have several pieces of equipment. |
|
|
|
|
|
|
|
|
· Each piece of equipment can have more than one supplier. |
|
|
|
|
|
|
|
|
· Each supplier can provide a variety of pieces of equipment. |
|
|
|
|
|
|
|
|
· Each department can have a restricted list of suppliers. |
|
|
|
|
|
|
|
|
Although each of the preceding business rules are simple, putting them all together in the database design is tough. It's the last item that really complicates things. There is more than one way to solve this kind of puzzle. The one suggested here is just one of the many possibilities. |
|
|
|
|
|
|
|
|
First, you need to expose all the tables that you need to contain the data. The preceding list describes two one-to-many relationships (department to equipment, and department to supplier, with restrictions) and one many-to-many relationship (equipment to supplier, supplier to equipment). Each of those relationships can be expressed in simple tables. Two additional tables not mentioned, but certainly needed, are a table of all the equipment in the building (regardless of its location) and a table of all the suppliers (regardless of their department affiliation). Table 16.5 shows sample field layouts for the required tables. The Equipment and Supplier tables are shortened in this example. If you were designing these tables for a real database project, you would add several other fields. |
|
|
|
|
| Table 16.5. The Fifth Rule sample data tables. | | Equipment | Supplier | | EquipID | SupplierID | | EquipName | SupplierName | | DatePurchased | SupplierAddress |
|
|
|
|
|
|
Listing 16.8 contains the SQL DDL statements to create these tables. Figure 16.7 shows the results of executing these statements. |
|
|
|
|
|